#include <GL/freeglut.h>

void display()
{
    glColor3f(0, 1, 0);
    glBegin(GL_TRIANGLES);
    glVertex2f(0.5, 0.5);
    glVertex2f(-0.5, 0.5);
    glVertex2f(0, -0.5);
    glEnd();
    glFlush();
}

int main(int argc, char *argv[])
{

    glutInit(&argc, argv); // 初始化
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // 使用单个帧缓存、颜色模式为RGB
    glutInitWindowPosition(300, 300);
    glutCreateWindow("绘制三角形");
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}
